{% extends "base.html" %}
{% block title %}课程列表{% endblock %}
{% block content %}
    <h2>课程信息</h2>

    <table class="table">
        <thead>
            <tr>
                <th>ID</th>
                <th>课程名称</th>
                <th>授课教师</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for course in courses %}
            <tr>
                <td>{{ course.id }}</td>
                <td>{{ course.name }}</td>
                <td>{{ course.teacher.username }}</td>
                <td>
                    {% if session['is_admin'] %}
                    <a href="{{ url_for('edit_course', id=course.id) }}" class="btn btn-warning btn-sm">编辑</a>
                    <a href="{{ url_for('delete_course', id=course.id) }}" class="btn btn-danger btn-sm">删除</a>
                    {% endif %}
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table><br>
    {% if session['is_admin'] %}
    <a href="{{ url_for('add_course') }}" class="btn btn-primary mb-3">添加课程</a>
    {% endif %}
    <br>
    <a href="{{url_for('logout')}}" class="btn btn-secondary mb-3">登出</a>
{% endblock %}
